'use strict';

angular.module('afasApp')
.directive('popOver', function ($compile) {
  var itemsTemplate = "<textarea class='form-control' ng-model='items'></textarea>";
  var getTemplate = function (contentType) {
    var template = '';
    switch (contentType) {
      case 'items':
      template = itemsTemplate;
      break;
    }
    return template;
  }
  return {
    restrict: "A",
    transclude: true,
    template: "<span ng-transclude></span>",
    link: function (scope, element, attrs) {
      var popOverContent;
      if (scope.items) {
      } else {
        scope.items = 'note';
      }
      var html = getTemplate("items");
      popOverContent = $compile(html)(scope);
      var options = {
        content: popOverContent,
        placement: "top",
        html: true
      };
      $(element).popover(options);
    },
    scope: {
      items: '='
    }
  };
});
